package com.chuji.crmcj.view;

/**
 * Created by y.yiwen on 1/21/2016.
 */
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.chuji.crmcj.R;


public class DivisionEditText extends EditText{
    public DivisionEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private String oldText = "";

    @Override
    protected void onDraw(Canvas canvas) {
        String text = getText().toString();
        text = text.replace(",", "");
        if (!oldText.equals(text)) {
            oldText = text;
            StringBuilder builder = new StringBuilder();
            for (int i =0;i<text.length(); i++) {
                    builder.append(text.charAt(i)).append(",");
            }
            setText(builder);
            setSelection(builder.length());
        }
        super.onDraw(canvas);
    }

}